﻿using CJAtech.BBS.Business;
using CJAtech.BBS.DataEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Bigger.Base.Cache;
using Bigger.Framework;
using Bigger.Web.Helper;

namespace CJAtech.BBS.Process
{
    public partial class BBSBaseProcess
    {
        public CommunityConfig CurrentCommunityConfig { get; private set; }
        public BBSBaseProcess(string bbsName)
        {
            this.CurrentCommunityConfig = GetCommunityConfig(bbsName);
        }

        public virtual CommunityConfig GetCommunityConfig(string bbsName)
        {
            CommunityConfig objCommunityConfig = SystemWebAsset.HttpContext.GetItems("CommunityConfig") as CommunityConfig;
            if (objCommunityConfig == null)
            {
                BizCommunityConfig objBizCommunityConfig = new BizCommunityConfig();
                objCommunityConfig = objBizCommunityConfig.GetRecordCache("", TimeSpan.FromSeconds(10), "ConfigCode=@ConfigCode", new { ConfigCode = bbsName });
            }
            return objCommunityConfig;
        }

        public virtual UserInfo GetUserInfo()
        {
            //UserInfo objUserInfo=
            return HttpContext.Current.GetItems("UserInfo") as UserInfo ?? new UserInfo
            {
                UserId = SystemWebAsset.GetClientIP(),
                UserName = "网友",
                Avatar = ""
            };

        }
    }
}
